home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / bnchutil.arc / QSORT.DOC < prev    next >
Encoding:
Text File  |  1991-04-30  |  77.4 KB  |  1,651 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                                           
  23.  
  24.  
  25.                                           
  26.  
  27.  
  28.                                QSORT -- Version 3.22
  29.                                QSORT -- Version 3.22
  30.                                           
  31.                              Text File Sorting Utility
  32.                              Text File Sorting Utility
  33.                                           
  34.                                           
  35.                                           
  36.                                           
  37.                                           
  38.                                           
  39.                                           
  40.                                           
  41.                                           
  42.                                           
  43.  
  44.  
  45.                        Copyright 1985, 86, 87, 88 - Ben Baker
  46.                        Copyright 1985, 86, 87, 88 - Ben Baker
  47.                                           
  48.                                 All rights reserved
  49.                                 All rights reserved
  50.  
  51.  
  52.                                           
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.                                  Table of Contents
  78.                                  Table of Contents
  79.  
  80.  
  81.  
  82.        Introduction                                                1
  83.           About Shareware                                          1
  84.           Notation                                                 2
  85.  
  86.        The QSORT Command and Options                               3
  87.           The /<key_spec> Parameter                                4
  88.           The /F<len> Parameter                                    5
  89.           The /T[<tag>] Parameter                                  5
  90.           The /D[<fields>][<delim>[<term>]] Parameter              6
  91.           The /R Parameter                                         7
  92.           The /S[V] Parameter                                      7
  93.           The /? Parameter                                         9
  94.           The "2><error_file>" parameter                           9
  95.  
  96.        Lexicographic Sorting                                      11
  97.  
  98.        Examples                                                   12
  99.  
  100.        Error Messages and Return Codes                            14
  101.           Command Line Errors                                     15
  102.           Memory Errors                                           16
  103.           I/O Errors                                              17
  104.           Internal Errors                                         17
  105.           ERRORLEVEL Return Codes                                 18
  106.  
  107.        Implementation Notes                                       18
  108.           General Information                                     18
  109.           Performance and DOS Configuration                       19
  110.           Performance and Input Record Type                       21
  111.           Performance and Sort Keys                               22
  112.           Performance and File Size                               23
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                                         i
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.                                  Introduction
  148.                                  Introduction
  149.  
  150.  
  151.        QSORT was first designed to be a replacement for, and to overcome
  152.        the limitations  of DOS  SORT, but  has been enhanced a number of
  153.        times and moved to new compilers twice.  The current version will
  154.        sort files  whose size  is limited  only by available disk space.
  155.        File name(s)  may be  given explicitly  or QSORT  will sort  from
  156.        standard input  to standard  output, and so, may be used in pipes
  157.        or with  redirection.   Multiple keys  may be  specified.  Binary
  158.        files with fixed-length records may be sorted, provided only that
  159.        keys are ASCII character strings.
  160.  
  161.        QSORT tries  to be very protective of your data.  If QSORT has an
  162.        error of  any kind,  it will  terminate with the input file still
  163.        intact, and  will return to DOS with a non-zero ERRORLEVEL.  When
  164.        QSORT successfully  completes sorting  a file, it terminates with
  165.        ERRORLEVEL set to zero.
  166.  
  167.        The command  line syntax  is a super-set of DOS SORT's syntax, so
  168.        QSORT may  be used  without other  changes in  batch files  using
  169.        SORT, but  in most  cases you  will probably  want to make use of
  170.        QSORT's greater capabilities.
  171.  
  172.  
  173.        About Shareware
  174.        About Shareware
  175.  
  176.        QSORT is  the copyrighted  property of  Ben Baker.   It  is  dis-
  177.        tributed under  a license agreement with System Enhancement Asso-
  178.        ciates, Inc.  (SEA), and  is made available under the "shareware"
  179.        concept.  Shareware products are distributed freely and publicly.
  180.        You are invited to "test drive" them without cost.  But shareware
  181.        is NOT FREE!  If you use a product, you are expected to pay a fee
  182.        for its  use.  Because overhead costs are lower, this fee is usu-
  183.        ally a  fraction of the normal commercial price the product might
  184.        carry, but it is NOT zero!
  185.  
  186.        Both the author and SEA believe in the shareware concept.  We are
  187.        both opposed  to the  "crippleware" concept used by some authors,
  188.        by which a severely limited version of the product is distributed
  189.        publicly, and  the user must register in order to receive a func-
  190.                                ____                                     
  191.        tional version.  At the same time, we feel the user should be of-
  192.        fered more  incentive than  mere guilt  to register  a  shareware
  193.        product.
  194.  
  195.        We have  therefore adopted a policy of withholding the latest ma-
  196.        jor release of the QSORT program from shareware, and marketing it
  197.        only as  a commercial  product.  As of this writing, version 3.22
  198.        of the  QSORT program  is shareware and version 4.00 (see the ac-
  199.        companying history file) is a commercial product.  When version 5
  200.        is created,  the latest  release level  of version  4 will become
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.        QSORT Text Sorting Utility                                      2
  211.  
  212.  
  213.        shareware, etc..   Hence,  the version  of QSORT  you receive  as
  214.        shareware is  fully functional  and fully documented.  It is just
  215.        not the latest version available.
  216.  
  217.        If you  find this  program useful, non-commercial users are asked
  218.        to pay a license fee of $20 for each machine on which it is used.
  219.  
  220.        The license  fee for commercial use of QSORT is $35 for the first
  221.        machine.   Liberal quantity  discounts, and  site  licensing  are
  222.        available.
  223.  
  224.        On receipt  of your registration fee, you will be sent a diskette
  225.        containing the  latest commercial  version of  the QSORT  program
  226.                   ___  ______                                           
  227.        with on-disk  documentation.   The complete  commercial packagge,
  228.        including printed documentation and technical support is $50.
  229.  
  230.        This version of QSORT may be freely copied and distributed,  pro-
  231.        vided that  1) it  is distributed  under the name "QSORT," and 2)
  232.        the documentation file always accompanies it.
  233.  
  234.        Vendors wishing to distribute QSORT as a part of commercial prod-
  235.        ucts may  contact the author's representatives at the address be-
  236.        low for terms.
  237.  
  238.        Send checks or correspondence to:
  239.  
  240.             System Enhancement Associates, Inc.
  241.             21 New Street
  242.             Wayne, NJ 07470
  243.        
  244.             Phone: (201) 473-5153
  245.  
  246.  
  247.        Notation
  248.        Notation
  249.  
  250.        In defining  the command  line and  its various  parameters,  the
  251.        following notation is used:
  252.  
  253.        [<optional>] items are enclosed in square brackets.
  254.        [<optional>]                                       
  255.         __________                                        
  256.  
  257.        <variable> items  appear in lower case, underscored, and are
  258.        <variable>                                                  
  259.        __________                              ___________         
  260.             surrounded by  angle brackets  (<>).  They are replaced
  261.             by actual data such as a file name.
  262.  
  263.        THIS |  THAT   Choices are  separated  by  a  vertical  bar.
  264.        THIS |  THAT                                                
  265.             Select one or the other but not both.
  266.  
  267.        [THIS |  THAT]   When the  choices are  enclosed  in  square
  268.        [THIS |  THAT]                                              
  269.             brackets, they  are optional.    You  need  not  select
  270.             either.
  271.  
  272.        REPEAT. . .  The ellipsis (. . .) means the item to its left
  273.        REPEAT. . .                                                 
  274.             may be repeated as many times as necessary.
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.        QSORT Text Sorting Utility                                      3
  286.  
  287.  
  288.        UPPER CASE  items and  all special  characters  not  defined
  289.        UPPER CASE                                                  
  290.             above represent  themselves.   They are entered exactly
  291.             as they appear.
  292.  
  293.        EXAMPLES are shown in bold upper case characters.
  294.        EXAMPLES              bold                       
  295.  
  296.  
  297.  
  298.                          The QSORT Command and Options
  299.                          The QSORT Command and Options
  300.  
  301.  
  302.        QSORT is invoked with the following command:
  303.  
  304.             QSORT [<in_file>[<out_file>]] [/<key_spec>]. . .
  305.             QSORT [<in_file>[<out_file>]] [/<key_spec>]. . .
  306.                    _________ __________     __________      
  307.                  [/F<len> | /D[<fields>][<delim>[<term>] |
  308.                  [/F<len> | /D[<fields>][<delim>[<term>] |
  309.                     _____      ________  _______ ______   
  310.                  /T[<tag>]] [/R] [/S[V]] [/?] "[2><error_file>]"
  311.                  /T[<tag>]] [/R] [/S[V]] [/?] "[2><error_file>]"
  312.                     _____                         ____________  
  313.  
  314.        Note that  all parameters  on the command line are optional.  The
  315.        <in_file> and  <out_file> parameters  are "ASCII-Z"  file  speci-
  316.        _________      __________                                        
  317.        fiers.   They may  contain disk and path information in the stan-
  318.        dard DOS format, but must not contain "wild-card" characters.  If
  319.        <in_file> is missing, QSORT sorts from standard input to standard
  320.        _________                                                        
  321.        output.   These are  files defined and opened by DOS before QSORT
  322.        is loaded.   (See  your DOS manual concerning the use of redirec-
  323.        tion and pipes.)
  324.  
  325.        If <in_file>  is given but <out_file> is missing, QSORT creates a
  326.           _________               __________                            
  327.        temporary file in the directory containing <in_file> and sorts to
  328.                                                   _________             
  329.        the temporary  file.   On  successful  completion  of  the  sort,
  330.        <in_file> is  deleted and  the temporary is renamed to <in_file>.
  331.        _________                                              _________ 
  332.        The effect is an apparent "sort-in-place."
  333.  
  334.        If both  file names  are given,  <in_file> is  unchanged and  the
  335.                                         _________                       
  336.        sorted output  is written to <out_file>.  Note that the following
  337.                                     __________                          
  338.        two commands are exactly equivalent:
  339.  
  340.             QSORT  FILE.TXT  FILE.SRT
  341.             QSORT  FILE.TXT  FILE.SRT
  342.  
  343.             QSORT <FILE.TXT >FILE.SRT
  344.             QSORT <FILE.TXT >FILE.SRT
  345.  
  346.        In the  first, QSORT opens the files.  In the second, redirection
  347.        is specified  and DOS  opens the  files.  The result is the same.
  348.        It is  an error  QSORT can't  detect if  you mix  these.  For in-
  349.        stance:
  350.  
  351.             QSORT  FILE.TXT >FILE.SRT
  352.             QSORT  FILE.TXT >FILE.SRT
  353.  
  354.        will result  in a  sort-in-place.   QSORT will  open FILE.TXT but
  355.        won't know DOS has opened FILE.SRT for it, and will ignore it.
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.        QSORT Text Sorting Utility                                      4
  371.  
  372.  
  373.        The /<key_spec> Parameter
  374.        The /<key_spec> Parameter
  375.             __________          
  376.  
  377.        Up to  30 /<key_spec> parameters may be used to specify sort keys
  378.                  /                                                      
  379.                   __________                                            
  380.        and are  ordered  major  to  minor  from  left  to  right.    The
  381.        /<key_spec> argument has the form:
  382.        /                                 
  383.         __________                       
  384.  
  385.             /[L][+|-][<field>.][<col>][:<length>]
  386.             /[L][+|-][<field>.][<col>][:<length>]
  387.                       _______   _____   ________ 
  388.  
  389.        Note that  all elements  of this  argument are "optional," but at
  390.        least one element must be present following the slant-bar (/).
  391.                                                                  (/) 
  392.  
  393.        The 'L',  if present, specifies "lexicographic" sequence for this
  394.            'L'                                                          
  395.        key.   Lexicographic sequence is ordered first by spelling, then,
  396.        when keys have identical spelling, by capitalization.
  397.  
  398.        The minus (-) sign reverses the sorting order for this key, while
  399.                   -                                                     
  400.        the plus (+) sign (or no sign) specifies normal sort order.
  401.                  +                                                
  402.  
  403.        There are three numbers associated with every sort key: the field
  404.        number, the  starting column  within the field, and the length of
  405.        the key  in characters.   Any,  or all  of them may be given in a
  406.        /<key_spec> parameter.   QSORT  uses punctuation to identify each
  407.        /                                                                
  408.         __________                                                      
  409.        number.   A number followed by a period (.) is a field number.  A
  410.                                                 .                       
  411.        number preceded by a colon (:) is a length number.  A column num-
  412.                                    :                                    
  413.        ber has  no punctuation associated with it.  It follows the field
  414.        number, if any, and precedes the length number, if any.
  415.  
  416.        The  [<field>.]   element  is  used  only  for  "delimited-field"
  417.             [       .]                                                  
  418.              _______                                                    
  419.        records, and  locates this  key within  a particular  field.  The
  420.        value of  <field> must  be less  than or  equal to  the number of
  421.                  _______                                                
  422.        fields defined  with the /D parameter (see below).  If [<field>.]
  423.                                 /D                            [       .]
  424.                                                                _______  
  425.        is omitted  when sorting delimited-field records, the first field
  426.        is assumed.   For  consistency, all  records are  assumed to have
  427.        "fields."   In all cases except delimited-field records, there is
  428.        precisely one field, and it spans the entire record.
  429.  
  430.        If present,  [<col>] defines the beginning column of the key.  If
  431.                     [     ]                                             
  432.                      _____                                              
  433.        omitted, column  1 is  assumed.   In the  case of delimited-field
  434.        records, column 1 is the first character of the identified field.
  435.        In all  other cases,  column 1  is the  first  character  of  the
  436.        record.
  437.  
  438.        If present,  [:<length>] defines  the key  length in  columns (or
  439.                     [:        ]                                         
  440.                       ________                                          
  441.        characters).   If [:<length>] is omitted, the rest of the record,
  442.                          [:        ]                                    
  443.                            ________                                     
  444.        or field in delimited-field records, is assumed to be part of the
  445.        key.
  446.  
  447.        If no  key parameters are given, the entire record, or the entire
  448.        first field is the key.
  449.  
  450.        When sorting variable-length records, any key which begins beyond
  451.        the end  of its field in a particular record is treated as a null
  452.        (zero length)  key for that record, and will sort low relative to
  453.        all records  with non-null  values for  that key.   When  sorting
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.        QSORT Text Sorting Utility                                      5
  464.  
  465.  
  466.        fixed-length records,  all defined  keys must fall within the de-
  467.        fined record  length.  <key_spec> parameters must appear in order
  468.                               __________                                
  469.        of importance, primary key first.
  470.  
  471.  
  472.        The /F<len> Parameter
  473.        The /F<len> Parameter
  474.              _____          
  475.  
  476.        The /F<len>  parameter denotes  the record  length for  a file of
  477.            /F                                                           
  478.              _____                                                      
  479.        fixed-length records.   All records in the input file MUST be ex-
  480.        actly <len> bytes long.  The records need not (but may) be termi-
  481.              _____                                                      
  482.        nated with a CR/LF sequence.  They may contain any data, even bi-
  483.        nary data,  but the  keys must  be ASCII strings.  Strings may be
  484.        terminated with  a null (binary zero) character, or may be padded
  485.        with trailing spaces to the full length of the key.
  486.  
  487.        Note that QSORT does not attempt to support Pascal style strings.
  488.        These are strings which begin with a character whose binary value
  489.        is a  character count.  This is followed by <count> characters of
  490.                                                    _______              
  491.        ASCII data,  which in  turn is followed by random data out to the
  492.        maximum length of the string.  These strings may be used as keys,
  493.        but the  programmer must insure that either the last real charac-
  494.        ter is  a null character, or the key is padded to its full length
  495.        with spaces.   QSORT must be told that the key begins in the sec-
  496.        ond character position (the first character of real data).
  497.  
  498.  
  499.        The /T[<tag>] Parameter
  500.        The /T[<tag>] Parameter
  501.               _____           
  502.  
  503.        The /T[<tag>] parameter, if present, indicates that the "records"
  504.            /T[     ]                                                    
  505.               _____                                                     
  506.        to be sorted may be more than a single line long.
  507.  
  508.        If <tag>  is also  present, it  defines a character to be used to
  509.           _____                                                         
  510.        tag the  "end-of-record."   If <tag>  is not  present, the  first
  511.                                       _____                             
  512.        empty line  terminates the  record.   For this  purpose,  "empty"
  513.        means "no  characters." A  line containing  but a single space is
  514.        not empty!  A line may be "tagged" by placing the <tag> character
  515.        ___                                               _____          
  516.        anywhere on  the last line of a logical record.  The entire line,
  517.        including the  tag character  will appear as the last line of the
  518.        record.
  519.  
  520.        Some characters  cannot be  used to represent themselves in a DOS
  521.        command line.   For  that reason,  QSORT uses  codes to represent
  522.        them.   These codes are actually a pair of characters.  The first
  523.        is always  a back-slash (\).  The second character identifies the
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.        QSORT Text Sorting Utility                                      6
  544.  
  545.  
  546.        special character  it represents.   The  following is  a table of
  547.        characters recognized by QSORT:
  548.  
  549.                \B  - Space character
  550.                \B                   
  551.                \F  - Form feed character
  552.                \F                       
  553.                \L  - Line feed character
  554.                \L                       
  555.                \N  - Newline sequence
  556.                \N                    
  557.                \R  - Carriage return
  558.                \R                   
  559.                \T  - Tab character
  560.                \T                 
  561.                \/  - The slant bar character
  562.                \/                           
  563.                \\  - Back-slash character itself
  564.                \\                               
  565.  
  566.        Thus an invisible tab character might be used to end a multi-line
  567.        logical record.   The  other characters  in this  code list don't
  568.        make much  sense in  this context,  but will  be useful in the /D
  569.                                                                       /D
  570.        parameter (see  below).  Notice that the slant bar (/), when used
  571.                                                            /            
  572.        as a delimiter character in the /T or /D parameters, must be pre-
  573.                                        /T    /D                         
  574.        fixed by  the back-slant  to prevent it from being interpreted as
  575.        the beginning of a new parameter.
  576.  
  577.        Note that  the /F<len> and /T[<tag>] parameters are incompatible,
  578.                       /F          /T[     ]                             
  579.                         _____        _____                              
  580.        and may not both be specified.
  581.  
  582.  
  583.        The /D[<fields>][<delim>[<term>]] Parameter
  584.        The /D[<fields>][<delim>[<term>]] Parameter
  585.               ________  _______ ______            
  586.  
  587.        The /D[<fields>][<delim>[<term>]]  parameter, if  present, states
  588.            /D[        ][       [      ]]                                
  589.               ________  _______ ______                                  
  590.        that this file contains delimited-field records.  In other words,
  591.        a record is made up of distinct, variable length fields separated
  592.        from one  another by  a  particular  character,  or  "delimiter."
  593.        Records are separated, or "delimited" by the "newline sequence."
  594.  
  595.        The <fields> element defines the number of variable length fields
  596.            ________                                                     
  597.        contained in each record.  All fields must be present in each and
  598.        every record.   A "null" field will be represented by two succes-
  599.        sive delimiter characters.  There must always be exactly <fields>
  600.                                                                 ________
  601.        minus 1 delimiter characters in a record.
  602.  
  603.        If a  <delim> character  is present, QSORT uses it as a field de-
  604.              _______                                                    
  605.        limiter character.   Otherwise  a comma  (,) is assumed to be the
  606.        delimiter.
  607.  
  608.        If a  <term> character is also present, QSORT uses it as a record
  609.              ______                                                     
  610.        delimiter  character.    In  fact,  it  literally  redefines  the
  611.        "newline sequence" to QSORT.  More on this in a moment.
  612.  
  613.        The same  character codes  listed under  the /T  parameter may be
  614.                                                     /T                  
  615.        used to  represent these  characters.   Note that  "\N" means the
  616.                                                           "\N"          
  617.        "newline sequence."   If <term> is not present, this is the CR-LF
  618.                                 ______                                  
  619.        character pair.   If  <term> is present, it represents the <term>
  620.                              ______                               ______
  621.        character.  Thus:
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.        QSORT Text Sorting Utility                                      7
  635.  
  636.  
  637.             /D3\N\T
  638.             /D3\N\T
  639.  
  640.        says that  the newline  sequence is a tab character, and that the
  641.        three fields  within  each  record  are  also  separated  by  tab
  642.        characters.  On the other hand:
  643.  
  644.             /D3\N
  645.             /D3\N
  646.  
  647.        says that fields are separated by the newline sequence, thus each
  648.        group of  three lines  constitutes one  logical record,  and each
  649.        line is a field within that record.
  650.  
  651.        The /D  parameter is  always incompatible  with the /F parameter,
  652.            /D                                              /F           
  653.        and usually  incompatible with  the /T parameter, but there is an
  654.                                            /T                           
  655.        exception when <fields> is missing, or is equal to 1.
  656.                       ________                              
  657.  
  658.        If <fields>  equals 1  (or is missing) it says that there is only
  659.           ________                                                      
  660.        one field spanning the entire record.  But that is what QSORT as-
  661.        sumes if the whole /D parameter is missing!  So why bother?
  662.                           /D                                      
  663.  
  664.        In most  ASCII files a "line" ends with a carriage return charac-
  665.        ter (CR)  followed by a line feed character (LF).  QSORT searches
  666.        for this  character pair  when it  is looking  for a "newline se-
  667.        quence."
  668.  
  669.        But not  all files use CR-LF as a line terminator.  For instance,
  670.        files imported  from UNIX or XENIX usually terminate lines with a
  671.        naked line  feed character!  And some editors produce files whose
  672.        lines end in a naked carriage return character!  So:
  673.  
  674.             /D,\L
  675.             /D,\L
  676.  
  677.        says "for  this file,  the newline sequence is a single line feed
  678.        character."   In this  case, the  comma is a place holder.  There
  679.        really is  no "delimiter  character," but  one must be present in
  680.        the parameter in order to define the <term> character.
  681.                                             ______           
  682.  
  683.  
  684.        The /R Parameter
  685.        The /R Parameter
  686.  
  687.        The /R  parameter is included for compatibility with DOS SORT and
  688.            /R                                                           
  689.        is redundant.   It  reverses the  sense of sort direction for all
  690.        sort keys.
  691.  
  692.  
  693.        The /S[V] Parameter
  694.        The /S[V] Parameter
  695.  
  696.        The /S  parameter tells  QSORT to make a statistics report to the
  697.            /S                                                           
  698.        screen at  the end  of a  run.   The report  is  written  to  the
  699.        "standard error"  device, the console, and may not be redirected.
  700.        The following  is an  actual statistics  report  "cut"  from  the
  701.        screen after QSORT had sorted a 1.3+ megabyte file:
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.        QSORT Text Sorting Utility                                      8
  714.  
  715.  
  716.               12115 records sorted
  717.                 150 bytes in longest record
  718.          
  719.              127131 sort phase comparisons
  720.               73232 merge phase comparisons
  721.          
  722.              200363 total comparisons
  723.                16.5 comparisons per input record
  724.          
  725.                  27 temporary merge files created
  726.                   2 merge passes
  727.                 2.4 average passes over data
  728.          
  729.                2:51 elapsed time
  730.  
  731.        The first two numbers are self-explanatory.  The next two are the
  732.        number of  times two  records were compared during the sort phase
  733.        and the  merge phase  respectively, followed by the total compar-
  734.        isons.
  735.  
  736.        The next  number is  total comparisons  divided by  the number of
  737.        records in the input file.  If there is no merge phase, this num-
  738.        ber is  typically 10  to 12.   If the file is large enough to re-
  739.        quire merging,  it is 12 to 20, on average.  If it is much larger
  740.        than 20,  it usually  means that there is something unusual about
  741.        your input file.  It may already be sorted, or there may be large
  742.        blocks of  records which  compare equal.   This can happen if you
  743.        sort on, say column 50 and the input file contains a large number
  744.        of records  shorter than 50 bytes. In this case, a minor sort key
  745.        at column 1 may significantly speed sorting.
  746.  
  747.        The next  two items  are self-explanatory.   "Average passes over
  748.        data" reflects the number of times each record was read and writ-
  749.        ten.   For short  files not  requiring a  merge pass, this number
  750.        will be  1.0.  When merging is needed, the last merge pass is the
  751.        one which writes the output file and it must read and write every
  752.        record exactly  once.   Thus when  only one  merge pass  is made,
  753.        there will  be exactly  2.0 "average  passes over  data." In  the
  754.        above case  the first  merge pass  processed  about  40%  of  the
  755.        records, hence the value of 2.4.
  756.  
  757.        The above  sort was performed on a Zenith 248, an eight megahertz
  758.        AT clone  with two  hard drives (C and D).  The input file was on
  759.        C; the  temporary merge  files were  placed on  D; and the output
  760.        file was written to C:.  The sort of a 1.3 megabyte file took un-
  761.        der three  minutes.   The same  sort on  an XT  should take about
  762.        seven minutes.
  763.  
  764.        The optional  subparameter, [V]  (for verbose),  causes the QSORT
  765.                                    [V]                                  
  766.        program to  make running  progress reports  to the  screen.  Each
  767.        pass during  both the sort phase and the merge phase (if any) is-
  768.        sues a  1-line report telling the merge file(s) and the number of
  769.        records being processed during that particular pass.  This is not
  770.        terribly useful  for short  files, but  for the  big ones, it can
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.        QSORT Text Sorting Utility                                      9
  781.  
  782.  
  783.        give the  user a warm comfortable feeling that something is actu-
  784.        ally being done.
  785.  
  786.  
  787.        The /? Parameter
  788.        The /? Parameter
  789.  
  790.        The /?  parameter requests  help or  parameter evaluation.   When
  791.            /?                                                           
  792.        QSORT is  executed with  the /? parameter alone, it lists a short
  793.                                     /?                                  
  794.        description of  the QSORT parameters.  If /? is entered as one of
  795.                                                  /?                     
  796.        several parameters,  QSORT will  produce a  short report  on  the
  797.        screen describing the sort it would perform based on those param-
  798.        eters without actually doing a sort.
  799.  
  800.        For example:
  801.  
  802.             QSORT /? /L5:12 /-3:2 /22 /T /R <INFILE.TXT >OUTFILE.TXT
  803.             QSORT /? /L5:12 /-3:2 /22 /T /R <INFILE.TXT >OUTFILE.TXT
  804.  
  805.        produces the following screen report:
  806.  
  807.          With the present arguments, QSORT would sort from STDIN to
  808.          STDOUT
  809.          Records are multiple lines ending with an empty line
  810.          
  811.          Key fields in descending order of importance are:
  812.            Field  Pos   Len Type
  813.          
  814.                1    5    12 Lexical Descending
  815.                1    3     2 ASCII
  816.                1   22 65535 ASCII   Descending
  817.  
  818.        This display  lists everything  QSORT knows  about  the  proposed
  819.        sort.   It shows the file name(s), if known, or in this case, the
  820.        fact that  QSORT is  being used  as a "filter" and file names are
  821.        unknown.   It lists  file characteristics,  here showing that the
  822.        input file has records "tagged" with an empty line.  And it lists
  823.        characteristics of all defined key fields.  The third key in this
  824.        report has an unspecified length.  The value "65535" merely means
  825.        that this key extends to the end of each record.
  826.  
  827.  
  828.        The "2><error_file>" parameter
  829.        The "2><error_file>" parameter
  830.               ____________           
  831.  
  832.        The QSORT  program writes  its messages  and help  and statistics
  833.        screens to the DOS standard error device.  DOS allows the user to
  834.        redirect standard  input and  standard output,  as discussed ear-
  835.        lier, but  makes no provision for redirecting standard error.  As
  836.        far as  DOS is concerned, error messages belong on the screen and
  837.        nowhere else!
  838.  
  839.        The  "2><error_file>"   parameter  provides   the  capability  of
  840.             "2>            "                                            
  841.                ____________                                             
  842.        redirecting QSORT's  messages and  screens to  the file  named in
  843.        <error_file>.   UNIX users  should recognize  the syntax  immedi-
  844.        ____________                                                     
  845.        ately.   It is borrowed from the Bourne-Shell.  Some replacements
  846.        for DOS'  COMMAND.COM, such as Polytron's PloyShell, also support
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.        QSORT Text Sorting Utility                                     10
  857.  
  858.  
  859.        this syntax.  The  parameter should be enclosed in qupte marks as
  860.        shown to prevent later versions of DOS from trying to perform the
  861.        redirection wrong!
  862.                    wrong 
  863.                    _____ 
  864.  
  865.        Two variations on this parameter are also recognized by the QSORT
  866.        program.   "2>><error_file>" tells  QSORT to open <error_file> in
  867.                   "2>>            "                                     
  868.                       ____________                       ____________   
  869.        append mode  and add  the messages for this run to the end of the
  870.        contents already  in <error_file>.   2>&-  turns off  all message
  871.                                             2>&-                        
  872.                             ____________                                
  873.        output from QSORT.
  874.  
  875.        A space may be inserted in front of <error_file>, and if the file
  876.                                            ____________                 
  877.        name begins  with an  ampersand (&),  a space  must precede it to
  878.                                                       ____              
  879.        avoid confusion with the last form above and generating an error.
  880.  
  881.        To summarize:
  882.  
  883.             QSORT JUNK /S "2>MESSAGES.TXT"
  884.             QSORT JUNK /S "2>MESSAGES.TXT"
  885.  
  886.        sorts the  file JUNK  in place,  writing the statistics screen to
  887.        the file  MESSAGES.TXT.   If that  file already exists, it is re-
  888.        placed by the output of this QSORT run.
  889.  
  890.             QSORT JUNK /S "2>>MESSAGES.TXT"
  891.             QSORT JUNK /S "2>>MESSAGES.TXT"
  892.  
  893.        sorts the  file JUNK in place, appending the statistics screen to
  894.        the end of the file MESSAGES.TXT.
  895.  
  896.             QSORT JUNK /S "2>&-"
  897.             QSORT JUNK /S "2>&-"
  898.  
  899.        sorts the  file JUNK  in place.  The /S parameter is meaningless,
  900.                                             /S                          
  901.        since the  "2>&-" parameter  turns off  all message  output  from
  902.                   "2>&-"                                                
  903.                                                ___                      
  904.        QSORT!
  905.  
  906.        
  907.  
  908.        The /M<len>  supported in  earlier versions of QSORT is no longer
  909.            /M                                                           
  910.              _____                                                      
  911.        required, but  will be accepted (and ignored) by QSORT.  There is
  912.        no "hard-coded"  maximum record  length in  QSORT, but there is a
  913.        practical limit.  At some time during every sort, the two longest
  914.        records in  the input  file must be compared.  Therefore, the two
  915.        longest records  must be able to fit together in the sort buffer.
  916.        The sum  of their lengths cannot exceed about 50K -- not an alto-
  917.        gether unreasonable  limitation.   QSORT can  be shoe-horned into
  918.        tighter memory  and will  run if it can find 4K for a sort buffer
  919.        and 4K  for an  output buffer,  but the  two longest records must
  920.        still fit in the sort buffer together.
  921.  
  922.        Arguments may appear in any order on the command line except that
  923.        <in_file> must  appear before  <out_file>, and  /<key_spec> argu-
  924.                                                        /                
  925.        _________                      __________        __________      
  926.        ments must appear in descending order of importance.
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.        QSORT Text Sorting Utility                                     11
  941.  
  942.  
  943.                              Lexicographic Sorting
  944.                              Lexicographic Sorting
  945.  
  946.  
  947.        The lexicographic  sorting capability was born out of my own need
  948.        to sort  word lists  with mixed  capitalization.   ASCII sequence
  949.        produced some  bizarre results  when  words  beginning  with  'Z'
  950.        sorted before  those beginning with 'a.' Case-insensitive sorting
  951.        wasn't much  better  because  upper  and  lower  case  got  mixed
  952.        randomly.
  953.  
  954.        The following table will illustrate what I mean:
  955.  
  956.             INPUT        ASCII        CASE         LEXICO-
  957.                                       INSENSITIVE  GRAPHIC
  958.        
  959.             DeLaPort     Baker        Baker        Baker
  960.             DeLaPort     Baker        Baker        Baker
  961.             Smith        Brown        brown        Brown
  962.             Smith        Brown        brown        Brown
  963.             brown        DeAngelo     bRown        bRown
  964.             brown        DeAngelo     bRown        bRown
  965.             deLaPorte    DeLaPort     Brown        brown
  966.             deLaPorte    DeLaPort     Brown        brown
  967.             Deangelo     Deangelo     Deangelo     DeAngelo
  968.             Deangelo     Deangelo     Deangelo     DeAngelo
  969.             deAngelo     Deangelo     deangelo     Deangelo
  970.             deAngelo     Deangelo     deangelo     Deangelo
  971.             Brown        DelaPort     Deangelo     Deangelo
  972.             Brown        DelaPort     Deangelo     Deangelo
  973.             smith        DelaPorte    deAngelo     deAngelo
  974.             smith        DelaPorte    deAngelo     deAngelo
  975.             delaPorte    Harry        DeAngelo     deangelo
  976.             delaPorte    Harry        DeAngelo     deangelo
  977.             DelaPort     Smith        delaPort     DeLaPort
  978.             DelaPort     Smith        delaPort     DeLaPort
  979.             DeAngelo     bRown        DelaPort     DelaPort
  980.             DeAngelo     bRown        DelaPort     DelaPort
  981.             DelaPorte    brown        delaPort     delaPort
  982.             DelaPorte    brown        delaPort     delaPort
  983.             deangelo     deAngelo     DeLaPort     delaPort
  984.             deangelo     deAngelo     DeLaPort     delaPort
  985.             Harry        deLaPorte    DelaPorte    DelaPorte
  986.             Harry        deLaPorte    DelaPorte    DelaPorte
  987.             delaPort     deLaPorte    deLaPorte    deLaPorte
  988.             delaPort     deLaPorte    deLaPorte    deLaPorte
  989.             Baker        deangelo     delaPorte    deLaPorte
  990.             Baker        deangelo     delaPorte    deLaPorte
  991.             deLaPorte    delaPort     deLaPorte    delaPorte
  992.             deLaPorte    delaPort     deLaPorte    delaPorte
  993.             Deangelo     delaPort     Harry        Harry
  994.             Deangelo     delaPort     Harry        Harry
  995.             bRown        delaPorte    smith        Smith
  996.             bRown        delaPorte    smith        Smith
  997.             delaPort     smith        Smith        smith
  998.             delaPort     smith        Smith        smith
  999.  
  1000.        The first column is a list of names in arbitrary order.  The sec-
  1001.        ond is  an ASCII  sort of that list.  Third, we have one possible
  1002.        case-insensitive sort  of the  list.  The fourth column is what I
  1003.        really wanted.   It is sorted the way these words would be sorted
  1004.        in a  dictionary (or lexicon).  The third and fourth columns both
  1005.        collect words  of identical  spelling together,  but in the third
  1006.        column, upper  and lower  case spelling  are in  arbitrary order,
  1007.        while the fourth column places upper case spelling ahead of lower
  1008.        case spelling.
  1009.  
  1010.        For example, the two occurrences of Smith are widely separated in
  1011.                                            _____                        
  1012.        column 2 because one is capitalized and the other is not.  Column
  1013.        3 brings  the two  together, but  in the wrong order.  They might
  1014.        have been  in the  right order,  but the  order is strictly arbi-
  1015.        trary.   In column 4, Smith comes before smith, and lexicographic
  1016.                              _____              _____                   
  1017.        sorting will  always put  them in  this order.  Notice, also that
  1018.        the two occurrences of delaPort are not together in column 3, but
  1019.                               ________                                  
  1020.        are brought together in column 4.
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.        QSORT Text Sorting Utility                                     12
  1031.  
  1032.  
  1033.        Lexicographic sorting  is  achieved  by  making  case-insensitive
  1034.        comparisons of  entire keys.  If the keys compare equal, an ASCII
  1035.        comparison is  made to  arbitrate ties.   In  other  words,  when
  1036.        "lexicographic" keys  in two records have different spelling, the
  1037.        case-insensitive comparison  determines the order of the records.
  1038.        When  "lexicographic"  keys  are  spelled  the  same,  the  case-
  1039.        sensitive comparison determines the order of the records.
  1040.  
  1041.        Lexicographic keys  are defined,  as indicated  above, by placing
  1042.        the  letter  'L'  immediately  following  the  slant-bar  (/)  in
  1043.                     'L'                                          (/)    
  1044.        <key_spec> definitions.
  1045.        __________             
  1046.  
  1047.        Lexicographic sorting  can be  very useful  when needed,  but  be
  1048.        aware that  unnecessarily specifying  lexicographic ordering  may
  1049.        degrade performance of QSORT.
  1050.  
  1051.  
  1052.  
  1053.                                    Examples
  1054.                                    Examples
  1055.  
  1056.  
  1057.        Produce a  sorted directory listing and display it on the console
  1058.        a screen's worth at a time:
  1059.  
  1060.             A>DIR | QSORT | MORE
  1061.             A>DIR | QSORT | MORE
  1062.  
  1063.        This demonstrates the use of QSORT as a "filter" in a "pipe."
  1064.  
  1065.        
  1066.  
  1067.        Produce a directory listing sorted by creation date and time, and
  1068.        display it on the console a screen's worth at a time:
  1069.  
  1070.             A>DIR | QSORT /30:2 /24:5 /39 /34:5 | MORE
  1071.             A>DIR | QSORT /30:2 /24:5 /39 /34:5 | MORE
  1072.  
  1073.        The output  of the  DIR command  is piped to QSORT.  The keys de-
  1074.        fined are,  from left to right (major to minor), year (2 digits),
  1075.        month and  day, AM/PM flag and time.  The output of QSORT is then
  1076.        piped to MORE for display.
  1077.  
  1078.        
  1079.  
  1080.        Next, replace  the unsorted FILE.TXT with the same data sorted in
  1081.        reverse order.  Use columns 10 to 16 as the sort key:
  1082.  
  1083.             C> QSORT FILE.TXT /-10:7
  1084.             C> QSORT FILE.TXT /-10:7
  1085.  
  1086.                  or
  1087.                  or
  1088.  
  1089.             C> QSORT FILE.TXT /10:7 /R
  1090.             C> QSORT FILE.TXT /10:7 /R
  1091.  
  1092.                  or
  1093.                  or
  1094.  
  1095.             C> QSORT FILE.TXT /R /+10
  1096.             C> QSORT FILE.TXT /R /+10
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.        QSORT Text Sorting Utility                                     13
  1107.  
  1108.  
  1109.        
  1110.  
  1111.        Next, perform  a simple  sort on  a  file  with  up  to  240-byte
  1112.        records:
  1113.  
  1114.             C> QSORT LARGE.REC /M240
  1115.             C> QSORT LARGE.REC /M240
  1116.  
  1117.                  or
  1118.                  or
  1119.  
  1120.             C> QSORT LARGE.REC
  1121.             C> QSORT LARGE.REC
  1122.  
  1123.        Note that  the "/M240"  parameter is  no  longer needed, but will
  1124.                       "     "                                           
  1125.        not hurt.
  1126.  
  1127.        
  1128.  
  1129.        GLOSS.TXT is  an unsorted  glossary of terms.  The term being de-
  1130.        fined by  each entry  appears first, followed by several lines of
  1131.        definition.   The entries  are separated by empty lines.  Produce
  1132.        GLOSS.SRT, a sorted version of the glossary:
  1133.  
  1134.                  with redirection
  1135.                  with redirection
  1136.  
  1137.             C> QSORT /T  <GLOSS.TXT >GLOSS.SRT
  1138.             C> QSORT /T  <GLOSS.TXT >GLOSS.SRT
  1139.  
  1140.                  or without redirection
  1141.                  or without redirection
  1142.  
  1143.             C> QSORT /T   GLOSS.TXT  GLOSS.SRT
  1144.             C> QSORT /T   GLOSS.TXT  GLOSS.SRT
  1145.  
  1146.        
  1147.  
  1148.        A lawyer  keeps a  running log  of  his  billable  activities  in
  1149.        TIME.LOG.   The first  line of  each entry is "mm/dd/yy hh:mm ac-
  1150.        count#." He  always places  a tilde  (~) in the last line of each
  1151.        entry.   He wishes  to sort the log by account number, and by as-
  1152.        cending date and time within each account:
  1153.  
  1154.             C> QSORT  /16:7 /7:2 /1:5 /10:5 /T~  TIME.LOG
  1155.             C> QSORT  /16:7 /7:2 /1:5 /10:5 /T~  TIME.LOG
  1156.  
  1157.        
  1158.  
  1159.        The directory  of users  for a bulletin board system is kept in a
  1160.        binary file  of fixed-length  records 180  bytes long.   The user
  1161.        name is  a 26-character field beginning in the first position and
  1162.        the city/state  field is  a 16-character  field beginning  in the
  1163.        fortieth position.  Sort the file by city/state and name.
  1164.  
  1165.             C> QSORT /F180 /40:16 /1:26 USER.BBS
  1166.             C> QSORT /F180 /40:16 /1:26 USER.BBS
  1167.  
  1168.        
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.        QSORT Text Sorting Utility                                     14
  1183.  
  1184.  
  1185.        DB.TXT is  a delimited  field output  file from  dBASE III.  Each
  1186.        record contains  7 fields, delimited by commas.  Sort the file to
  1187.        the screen using field 3 as a sort key.
  1188.  
  1189.             C> QSORT /D7 /3. <DB.TXT
  1190.             C> QSORT /D7 /3. <DB.TXT
  1191.  
  1192.        Here, "standard input" has been redirected to the file.  Since no
  1193.        redirection is  given for  "standard output,"   DOS assigns it to
  1194.        the console by default.  This is not a "sort-in-place!"
  1195.                                         ___                   
  1196.  
  1197.        
  1198.  
  1199.        You have  received a member list from the Society of End-users of
  1200.        XENIX (SEX.LST).   Sort  the list by special interest (10 columns
  1201.        beginning at 70) and name (30 columns beginning at 1).  Note that
  1202.        the file  contains no  carriage return characters.  Since SEX.LST
  1203.        is a  very large  file, we  wish to obtain running status reports
  1204.        and a final statistics report.
  1205.  
  1206.             C> QSORT  SEX.LST /70:10 /1:30 /D,\L /SV
  1207.             C> QSORT  SEX.LST /70:10 /1:30 /D,\L /SV
  1208.  
  1209.        The /D  parameter is  used to  redefine the newline sequence as a
  1210.            /D                                                           
  1211.        naked line feed character.
  1212.  
  1213.        
  1214.  
  1215.        The file  LABEL.TXT contains mailing label images.  Each label is
  1216.        6 lines  (1 inch)  high.  Line six is always empty and line three
  1217.        is frequently  empty.  An extended Zip code always begins in col-
  1218.        umn 20  of line  5, and extends to the end of the line.  In order
  1219.        to take  advantage of  bulk mailing  rates, the  labels  must  be
  1220.        sorted into carrier route (CARRT) order.
  1221.  
  1222.             QSORT LABEL.TXT /5.20 /D6\N
  1223.             QSORT LABEL.TXT /5.20 /D6\N
  1224.  
  1225.        We must  use a "delimited field" sort rather than a "tagged line"
  1226.        sort for  two reasons:   1)  Line six is empty, not tagged with a
  1227.        special character.   When  line three is also empty a label would
  1228.        be broken  into two  pieces and separated by the sorting process.
  1229.        2) Our  sort key is not at any known offset from the beginning of
  1230.        the label.  Its position is fixed only relative to line five.
  1231.  
  1232.  
  1233.  
  1234.                         Error Messages and Return Codes
  1235.                         Error Messages and Return Codes
  1236.  
  1237.  
  1238.        The QSORT program can encounter a number of different errors dur-
  1239.        ing execution.   Each will generate a brief error message on your
  1240.        console.   This section will attempt to list the messages you may
  1241.        see, and  give you  a little more detailed information about what
  1242.        might have caused the problem.
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.        QSORT Text Sorting Utility                                     15
  1255.  
  1256.  
  1257.        Command Line Errors
  1258.        Command Line Errors
  1259.  
  1260.        The most  common causes  of error messages are errors in the com-
  1261.        mand line  parameters.  Particularly when using a complicated set
  1262.        of keys,  I recommend  the use of "/?" as the last parameter.  If
  1263.                                          "/?"                           
  1264.        QSORT discovers an error, it will be reported.  The QSORT program
  1265.        will also  show you exactly what it would have done, had the "/?"
  1266.                                                                     "/?"
  1267.        parameter not been there, but will not perform a sort.
  1268.                                           ___                
  1269.  
  1270.        You may then hit the "F3" key to recall the command, edit any bad
  1271.                             "F3"                                        
  1272.        parameters using the left and right cursor keys and the "INS" and
  1273.        "DEL" keys.   When  the command parses without error, and the re-
  1274.        port looks  like the  kind of sort you wish to make, hit the "F3"
  1275.                                                                     "F3"
  1276.        key once  more, then back space over the "/?" parameter, then hit
  1277.                                                 "/?"                    
  1278.        "Enter" and QSORT will do the rest.
  1279.  
  1280.        One or  more of  the following errors might be encountered in the
  1281.        command line:
  1282.  
  1283.             Three file names specified
  1284.             Three file names specified
  1285.  
  1286.        At most,  only two  file names may be given, an input file and an
  1287.        output file.  The most likely cause of this message is forgetting
  1288.        to use  the "/" character at the beginning of a key spec or other
  1289.                    "/"                                                  
  1290.        parameter.
  1291.  
  1292.             Invalid command line parameter "<parameter>"
  1293.             Invalid command line parameter "<parameter>"
  1294.                                             ___________ 
  1295.  
  1296.        This message  is issued if QSORT receives a parameter it does not
  1297.        understand.   It is  usually a typographic error.  You meant "/D"
  1298.                                                                     "/D"
  1299.        and hit  "/E" by  mistake.    The  message  displays  the  actual
  1300.                 "/E"                                                    
  1301.        <parameter> it did not understand.
  1302.        ___________                       
  1303.  
  1304.             /D, /F and /T parameters are incompatible
  1305.             /D, /F and /T parameters are incompatible
  1306.  
  1307.        Each of the above parameters tells QSORT to use a different scan-
  1308.        ning routine  to parse  records.  Since only one such routine can
  1309.        be used, it is an error to use more than one of these parameters.
  1310.        In those  unusual situations where more than one might apply, use
  1311.        the most  efficient one.   (The  order of  the parameters in this
  1312.        message is  from most efficient to least efficient.  See the sec-
  1313.        tion on  "Performance and  Input Record  Type" for  more informa-
  1314.        tion.)
  1315.  
  1316.             Multiple /<parameter> parameters encountered
  1317.             Multiple /<parameter> parameters encountered
  1318.                       ___________                       
  1319.  
  1320.        This message  again applies  to the /D, /F and /T parameters.  In
  1321.                                            /D  /F     /T                
  1322.        this case, the same parameter appears twice in the command line.
  1323.  
  1324.             /F<length> parameter with invalid <length>
  1325.             /F<length> parameter with invalid <length>
  1326.  
  1327.        No substitution  is made for "<length>" in this message.  This is
  1328.                                     "<length>"                          
  1329.        the actual  message displayed.  It means that either there was no
  1330.        length specified, or the specified length was zero.
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.        QSORT Text Sorting Utility                                     16
  1341.  
  1342.  
  1343.             Keyfield "<key_spec>" begins beyond end of record
  1344.             Keyfield "<key_spec>" begins beyond end of record
  1345.                       __________                             
  1346.  
  1347.             Keyfield "<key_spec>" extends beyond end of record
  1348.             Keyfield "<key_spec>" extends beyond end of record
  1349.                       __________                              
  1350.  
  1351.        These two messages refer to fixed-length records.  A key specifi-
  1352.        cation has  told QSORT  that data exists beyond the bounds of the
  1353.        record.   For instance,  suppose that  /F20 has  been  specified.
  1354.                                               /F20                      
  1355.        Then /23  would invoke  the first  message because  the record is
  1356.             /23                                                         
  1357.        only 20  characters long.   Similarly /18:5 begins before the end
  1358.                                              /18:5                      
  1359.        of the  record but extends beyond it, and would invoke the second
  1360.        message.   Note that  /18 is  OK.   QSORT will assume a length of
  1361.                              /18                                        
  1362.        three in this case.
  1363.  
  1364.             Invalid delimited field specification - "<key_spec>"
  1365.             Invalid delimited field specification - "<key_spec>"
  1366.                                                      __________ 
  1367.  
  1368.        This one is similar to the previous messages.  The "field number"
  1369.        portion of  a key specification was greater than the defined num-
  1370.        ber of fields.  For example "/D5 /6.1:3" would provoke QSORT into
  1371.                                    "/D5 /6.1:3"                         
  1372.        issuing this  message.   It's hard  to find  field 6 in a 5-field
  1373.        record.
  1374.  
  1375.             Multiple STDERR redirections
  1376.             Multiple STDERR redirections
  1377.  
  1378.        At most,  the standard  error output  may be  redirected once.  A
  1379.        second attempt to do so will fail with this message.
  1380.  
  1381.             Invalid STDERR redirection
  1382.             Invalid STDERR redirection
  1383.  
  1384.        Two conditions  cause this  message; use of 2> or 2>> as the last
  1385.                                                    2>    2>>            
  1386.        parameter, with  no file specified, or use of 2>&<x> where <x> is
  1387.                                                      2>&                
  1388.                                                         ___       ___   
  1389.        any text other than an unadorned hyphen.
  1390.  
  1391.             ABORT -- Error(s) in command line parameter(s)
  1392.             ABORT -- Error(s) in command line parameter(s)
  1393.  
  1394.        If any  of the  above messages are issued, QSORT will continue to
  1395.        scan the command line and evaluate the parameters, but will even-
  1396.        tually issue this message too.  If there are command line errors,
  1397.        QSORT will not guess about your data.  It will stop!
  1398.                   ___                                      
  1399.  
  1400.  
  1401.        Memory Errors
  1402.        Memory Errors
  1403.  
  1404.             ABORT -- Buffer allocation error
  1405.             ABORT -- Buffer allocation error
  1406.  
  1407.        An error  of unknown origin occurred when QSORT was trying to al-
  1408.        locate memory  for its  buffers.  The most likely cause here is a
  1409.        "memory poor"  condition caused  by a too small partition under a
  1410.        multitasker such  as DoubleDOS,  or perhaps  too many "terminate-
  1411.        and-stay-resident" programs.   As an absolute minimum, QSORT must
  1412.        be able  to obtain  eight kilobytes  of contiguous memory for its
  1413.        sort buffer.
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.        QSORT Text Sorting Utility                                     17
  1427.  
  1428.  
  1429.             ABORT -- Insufficient memory
  1430.             ABORT -- Insufficient memory
  1431.  
  1432.        This one  can occur at any time during the sort.  QSORT must have
  1433.        a sort buffer large enough to hold the two largest records in the
  1434.        file.  Typically, the sort buffer is about fifty kilobytes, which
  1435.        means that  if records  are shorter  than about twenty five kilo-
  1436.        bytes, QSORT can usually handle them.  This is normally a problem
  1437.        only when using the /T parameter.
  1438.                            /T           
  1439.  
  1440.  
  1441.        I/O Errors
  1442.        I/O Errors
  1443.  
  1444.             ABORT -- Unable to open "<file_spec>" for input
  1445.             ABORT -- Unable to open "<file_spec>" for input
  1446.                                      ___________           
  1447.  
  1448.        QSORT  was   attempting  to  open  <file_spec>  for  input.    If
  1449.                                           ___________                   
  1450.        <file_spec> is your input file, you probably misspelled the name.
  1451.        ___________                                                      
  1452.        If <file_spec>  has the  form "number.SRT" QSORT could not find a
  1453.           ___________                                                   
  1454.        merge file  it thought  it had  created.  If this happens you may
  1455.        have discovered a bug.  Please send me full particulars ASAP!
  1456.  
  1457.             ABORT -- Unable to open "<file_spec>" for output
  1458.             ABORT -- Unable to open "<file_spec>" for output
  1459.                                      ___________            
  1460.  
  1461.        QSORT was attempting to open <file_spec> for output, and the open
  1462.                                     ___________                         
  1463.        operation failed.   The  most likely cause is that you ran out of
  1464.        disk space,  and DOS was unable to expand a subdirectory.  A root
  1465.        directory cannot  be expanded, and you may have run out of direc-
  1466.        tory space.  DOS will also complain if you attempt to open a file
  1467.        with the same full name as an existing subdirectory.
  1468.  
  1469.             ABORT -- Error reading input or merge file
  1470.             ABORT -- Error reading input or merge file
  1471.  
  1472.        The section  of the  program which  issues this  message does not
  1473.        know the  file name, so cannot help you much there.  This message
  1474.        may mean  that your disk has a sector going bad.  (Well, it can't
  1475.        all be good news!)
  1476.  
  1477.             ABORT -- Error writing to merge or output file
  1478.             ABORT -- Error writing to merge or output file
  1479.  
  1480.        This one  could also  mean a  bad sector,  but a  far more likely
  1481.        cause is that you just ran out of disk space.
  1482.  
  1483.  
  1484.        Internal Errors
  1485.        Internal Errors
  1486.  
  1487.             ABORT -- Internal QSORT error
  1488.             ABORT -- Internal QSORT error
  1489.  
  1490.        In theory,  this is  an error  which "can't happen."  If you EVER
  1491.                                             _______________             
  1492.        get this  message, please  notify me  with as many details as you
  1493.        can supply.   Actually I have NEVER seen this message issued by a
  1494.        released version of QSORT.
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.        QSORT Text Sorting Utility                                     18
  1509.  
  1510.  
  1511.        ERRORLEVEL Return Codes
  1512.        ERRORLEVEL Return Codes
  1513.  
  1514.        When QSORT  successfully completes a sort, it terminates with DOS
  1515.        ERRORLEVEL set to zero. (See your DOS manual for more information
  1516.        on ERRORLEVEL.)   If  it terminates for ANY other reason, it sets
  1517.        ERRORLEVEL to  a non-zero  value, which  can be tested in a batch
  1518.        file.   The following  are the  ERRORLEVEL codes  QSORT uses, and
  1519.        their meanings:
  1520.  
  1521.         Code  Meaning
  1522.        
  1523.  
  1524.            0  Successful completion
  1525.            1  Command line error and/or "/?" parameter specified
  1526.                                         "/?"                    
  1527.            2  Open-for-read error
  1528.            3  Open-for-write error
  1529.            4  I/O error reading file
  1530.            5  I/O error writing file
  1531.            6  Memory error
  1532.          255  Internal error
  1533.  
  1534.  
  1535.  
  1536.                              Implementation Notes
  1537.                              Implementation Notes
  1538.  
  1539.  
  1540.  
  1541.        General Information
  1542.        General Information
  1543.  
  1544.        QSORT is intended as an enhanced replacement for DOS SORT.  It is
  1545.        nearly fully  upward compatible,  but provides  much more  flexi-
  1546.        bility.   Multiple sort  keys may be specified, a pseudo in-place
  1547.        sort may be performed and files and/or records of any size may be
  1548.        sorted provided only that there is sufficient disk space for work
  1549.        files and  the output  file.   QSORT uses  the "quick sort" algo-
  1550.        rithm, which cannot guarantee the order of records whose keys are
  1551.        all equal.   This  is the  one "incompatibility"  with DOS  SORT,
  1552.        which retains  the original  order of  records when  its only key
  1553.        compares equal.  This is important to SORT because it must be in-
  1554.        voked multiple  times to effect a multiple key sort.  With QSORT,
  1555.        you only sort once and there are usually enough keys available to
  1556.        insure you get the order you want the first time.
  1557.  
  1558.        QSORT uses  a sort  buffer of  about 50K  bytes and will fill the
  1559.        buffer as  full as  possible, and then sort its contents.  If the
  1560.        end of  the input  file has  been reached  and no  temporary work
  1561.        files have  been generated, the sorted contents of the buffer are
  1562.        written to the output file, completing the sort operation.
  1563.  
  1564.        If the  input file  is too  large to fit into the sort buffer, as
  1565.        much of  the input  file as  possible is  read into  the  buffer,
  1566.        sorted, then  written to  a temporary work file.  This process is
  1567.        repeated as  many times  as necessary to process the entire input
  1568.        file, each time creating a new work file for the sorted output.
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.        QSORT Text Sorting Utility                                     19
  1579.  
  1580.  
  1581.        Upon completion  of the  "sort  phase,"  QSORT  begins  a  "merge
  1582.        phase."   Each work  file is  a sorted sub-set of the input file.
  1583.        Thus, work files may be read sequentially and combined to produce
  1584.        a sorted  output.  QSORT will open as many work files as DOS per-
  1585.        mits (more  on this  later).  If all the remaining work files can
  1586.        be opened,  the sorted  result is  written to  the  output  file.
  1587.        Otherwise, a new work file is created and another merge pass will
  1588.        be required.  On each merge pass, the number of work files is re-
  1589.        duced and  eventually all remaining work files will be opened and
  1590.        the sorted  output file will be written completing the sort oper-
  1591.        ation.
  1592.  
  1593.  
  1594.        Performance and DOS Configuration
  1595.        Performance and DOS Configuration
  1596.  
  1597.        QSORT is smart enough to never have just one work file remaining,
  1598.        which would  require an  unnecessary copy  operation.   In  fact,
  1599.        QSORT is  smarter than  just that  in its  handling of  the merge
  1600.        phase.   If more  than one  merge pass  is required, all the data
  1601.        merged during  the first  pass will  have to  be merged again, so
  1602.        QSORT attempts to minimize the first pass.  For example, if QSORT
  1603.        discovers it  may only  open 15 files at a time, and there are 16
  1604.        temporary files,  it will only merge two files on the first pass,
  1605.        creating a  17th file  as it  does.   Then in the second pass, it
  1606.        will merge  all 15  remaining files to the output file.  The less
  1607.        data it processes twice, the faster it performs the sort!
  1608.  
  1609.        With nothing  else to  guide it, QSORT places its temporary files
  1610.        in the  default directory.  Either of two "environment variables"
  1611.        can override this.  (See your DOS manual for information on envi-
  1612.        ronment variables and the SET command.) The DOS command:
  1613.  
  1614.             SET QSTMP=<path>        or
  1615.             SET QSTMP=<path>        or
  1616.                       ______          
  1617.  
  1618.             SET TMP=<path>          or
  1619.             SET TMP=<path>          or
  1620.                     ______            
  1621.  
  1622.             SET TEMP=<path>
  1623.             SET TEMP=<path>
  1624.                      ______
  1625.  
  1626.        will define  a path  for QSORT to use for its temporaries.  QSORT
  1627.        first looks  for the  environment variable QSTMP.  If it does not
  1628.        exist, QSORT  next looks  for TMP or TEMP in that order.  TMP and
  1629.        TEMP are  de facto  standards used by many programs, and are usu-
  1630.        ally defined in your AUTOEXEC.BAT batch file.  You might have TMP
  1631.        specifying a  64K RAM  disk to  speed up  your compiler.  In this
  1632.        case, an  attempt to  sort a  100K file  is  doomed  to  failure.
  1633.        Rather than  redefine TMP, you may define QSTMP to force QSORT to
  1634.        use some directory on your hard disk.  In fact:
  1635.  
  1636.             SET QSTMP=\
  1637.             SET QSTMP=\
  1638.  
  1639.        tells QSORT  to always  use the  root directory  of  the  default
  1640.        drive!
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.        QSORT Text Sorting Utility                                     20
  1653.  
  1654.  
  1655.             CAUTION! The  root directory  has a  fixed size, and is
  1656.             CAUTION! The  root directory  has a  fixed size, and is
  1657.             NOT expandable.  For a hard disk, it typically has room
  1658.             NOT expandable.  For a hard disk, it typically has room
  1659.             for only 512 file names, less one for each subdirectory
  1660.             for only 512 file names, less one for each subdirectory
  1661.             and one for the volume label (if any).  Large files may
  1662.             and one for the volume label (if any).  Large files may
  1663.             fail to  sort if  the QSORT program must place too many
  1664.             fail to  sort if  the QSORT program must place too many
  1665.             merge files  in a  root directory.   Subdirectories, on
  1666.             merge files  in a  root directory.   Subdirectories, on
  1667.             the other  hand, are  limited only  by  available  disk
  1668.             the other  hand, are  limited only  by  available  disk
  1669.             space.
  1670.             space.
  1671.  
  1672.        QSORT, to work properly, needs enough space on the output disk to
  1673.        hold the  output file.   Even  if the input file is to be deleted
  1674.        and resides  in the  same directory, that is not done until after
  1675.        the output file has been successfully written.  If one merge pass
  1676.        is required,  the disk space QSORT uses for temporary merge files
  1677.        will be  about 10%  larger than  the size  of the input file.  If
  1678.        more than  one merge pass will be required, allow about twice the
  1679.        size of the input file as temporary merge file space.
  1680.  
  1681.        One of  the advantages of controlling where QSORT places its tem-
  1682.        porary files  is to  insure adequate space for them.  A second is
  1683.        speed.   If the  temporary files can be placed on a separate disk
  1684.        from the  input and  output files,  disk seeking is minimized and
  1685.        performance improved.
  1686.  
  1687.        Each time  QSORT must create a new temporary merge file, the data
  1688.        put into  it will  be processed again.  Obviously, the more files
  1689.        QSORT can  open during  the merge  phase, the fewer times it will
  1690.        have to  handle each  record and  the faster  it can  sort  large
  1691.        files.   If DOS is properly pre-conditioned, QSORT can have up to
  1692.        15 temporary  merge files  open at once, and very large files can
  1693.        be sorted  with just  one sort pass and one merge pass.  Unfortu-
  1694.        nately, that capability is not automatic.
  1695.  
  1696.        DOS has  a fixed number of file "handles" that it associates with
  1697.        open files.   The  default number is eight, but DOS opens five of
  1698.        them for  standard input,  standard output, standard error, stan-
  1699.        dard printer  and standard  auxiliary device.   That leaves three
  1700.        for merging.   A  250K input  file would  produce five  temporary
  1701.        merge files  and that  would take  three merge  passes; merge two
  1702.        into one, leaving four; merge two into one leaving three; and fi-
  1703.        nally merge  three into  the output  file.  In the process, QSORT
  1704.        must read  and write about 80% of the file twice during the merge
  1705.        phase.
  1706.  
  1707.        Worse yet,  since you need at least three handles for merging, if
  1708.        you have  resident programs that have open files, you can't merge
  1709.        at all!
  1710.  
  1711.        DOS can  be told  to set aside more space for file handles.  Each
  1712.        handle is  only 39  bytes and  it's memory  very well spent.  One
  1713.        process can  have a  maximum of  20 handles open at one time, but
  1714.        since resident  processes may be using handles, I recommend 25 to
  1715.        35.  To do this, the root directory of the disk or disks you boot
  1716.                                                   ______________________
  1717.        from must  contain a file named CONFIG.SYS.  If your boot disk(s)
  1718.        ____                                                             
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.        QSORT Text Sorting Utility                                     21
  1729.  
  1730.  
  1731.        already contains  a CONFIG.SYS,  edit it, or if not, create it to
  1732.        contain the following line:
  1733.  
  1734.             FILES=25        (or more)
  1735.             FILES=25        (or more)
  1736.  
  1737.        While we're  at it,  let's add one more thing to CONFIG.SYS which
  1738.        will improve  the performance of QSORT and many other programs as
  1739.        well.  DOS provides, by default, two disk buffers.  These are the
  1740.        buffers it  uses to  do its  disk reads  and writes.   During the
  1741.        merge phase  QSORT may have many files open at once, reading from
  1742.        them in more or less random order.  DOS may have to read the same
  1743.        physical sector  several times  to get all its data.  But DOS can
  1744.        remember what's  in each  buffer and where it came from, and will
  1745.        not re-read  a sector  it already has in a buffer.  DOS needs 528
  1746.        bytes for each buffer.  I recommend 20 buffers to make QSORT per-
  1747.        form well  under the  most adverse conditions.  This will require
  1748.        an additional  9504 bytes  or slightly more than 9K, again memory
  1749.        well spent, so we add to CONFIG.SYS the following line:
  1750.  
  1751.             BUFFERS=20
  1752.             BUFFERS=20
  1753.  
  1754.        See your DOS manual for more information on CONFIG.SYS.
  1755.  
  1756.  
  1757.        Performance and Input Record Type
  1758.        Performance and Input Record Type
  1759.  
  1760.        QSORT must  read and  parse logical  records before sorting them,
  1761.        then reassemble  them before  final output.   The type of records
  1762.        contained in  the file being sorted determines how much work this
  1763.        requires, and therefore has an impact on performance.
  1764.  
  1765.        The present version of QSORT can handle four record types: simple
  1766.        ASCII, tagged  ASCII, delimited field ASCII and fixed length, de-
  1767.        termined by  the presence  or absence of a /T, /D or /F parameter
  1768.                                                   /T  /D    /F          
  1769.        on the command line.
  1770.  
  1771.        Fixed length  records are very structured and require no parsing.
  1772.        Other things  equal, files  of fixed length records will sort the
  1773.        fastest.
  1774.  
  1775.        When parsing  simple ASCII  records, QSORT must find and mark the
  1776.        newline sequence,  then restore it for final output.  In general,
  1777.        this is relatively fast, but is affected by line length.  In par-
  1778.        ticular, lines  containing "over-strikes"  (naked  CR  characters
  1779.        followed by more data) can significantly slow down the parsing.
  1780.  
  1781.        Tagged ASCII  records are  parsed in  a fashion similar to simple
  1782.        ASCII records,  if a  tag character  is defined.   First  the tag
  1783.        character is  found, then  the next newline sequence is found and
  1784.        marked.   The time  required is  of course dependent on the total
  1785.        length of  the logical  record, but  is fairly  fast.   If no tag
  1786.        character is  defined, two  successive newline  sequences must be
  1787.        found.   This depends not only on total length, but the number of
  1788.        lines contained in a logical record.
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.        QSORT Text Sorting Utility                                     22
  1799.  
  1800.  
  1801.        To parse  a delimited field record with n fields, n minus one de-
  1802.                                               __        __              
  1803.        limiters must be found and marked, then the newline sequence must
  1804.        be found and marked.  It is similar to tagged records with no de-
  1805.        fined tag character, but because records of this type are usually
  1806.        shorter than  tagged records, parsing delimited field records may
  1807.        be a  little faster.   It is certainly slower than parsing simple
  1808.        ASCII records.
  1809.  
  1810.  
  1811.        Performance and Sort Keys
  1812.        Performance and Sort Keys
  1813.  
  1814.        The sort  keys defined  on the command line have a lot to do with
  1815.        QSORT's performance.   There  isn't much  you can  do by way of a
  1816.        strategy, when  you need a particular file sorted in a particular
  1817.        way, but you should at least be aware.
  1818.  
  1819.        Several decisions  must be  made in comparing two records.  Which
  1820.        field contains the current key?  Is the field long enough to con-
  1821.        tain the  key in  one, both  or neither  record?   Are  the  keys
  1822.        lexicographic or ASCII?  If the answers to any of these questions
  1823.        will remain  constant over  the course of a sort run, they should
  1824.        be answered once, not several thousand times!
  1825.  
  1826.        QSORT has  ten record  comparison routines  varying in  degree of
  1827.        complexity.   At the  beginning of  each sort  run it selects the
  1828.        simplest one  possible, based on the parameters given, to be used
  1829.        throughout the run.
  1830.  
  1831.        If no sort key parameters are given, the entire record is used as
  1832.        a key.   The  compare routine has no decisions it must make -- it
  1833.        simply compares  the two  strings handed it.  This is the "simple
  1834.        sort," and is the fastest possible case.
  1835.  
  1836.        A sort  key that  does not  begin at  the beginning of a variable
  1837.        length record,  may not  be contained  in a  particular record at
  1838.        all, while  a fixed  length record  is known to contain all keys.
  1839.        Other things equal, files of fixed length records will sort some-
  1840.        what faster because the compare routine does not have to test for
  1841.        "key containment."
  1842.  
  1843.        Lexicographic keys  are first  compared with a "case insensitive"
  1844.        technique.   Each character is tested to see if it is alphabetic.
  1845.        If it  is, it  is converted  to lower  case.   Then the converted
  1846.        character from each record is compared.  This is obviously slower
  1847.        than  directly   comparing  two   characters.     In  the   event
  1848.        lexicographic keys compare equal, they are compared a second time
  1849.        using a  direct compare technique!  Files with lexicographic keys
  1850.        sort slower than similar files without them.
  1851.  
  1852.        In the  case of  files with  delimited field records, the compare
  1853.        routine must  find the  correct field  for each key, determine if
  1854.        the keys  are contained  within the  fields, and  finally compare
  1855.        them.   The added  step of searching for fields slows record com-
  1856.        parison.
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.        QSORT Text Sorting Utility                                     23
  1867.  
  1868.  
  1869.        In general, the more complex the data, the more complex the sort-
  1870.        ing task and the longer it will take.  QSORT attempts to optimize
  1871.        its performance  by making as many decisions as it can about your
  1872.        data up  front, then  selecting a compare routine that makes only
  1873.        the necessary decisions on a record-by-record basis.
  1874.  
  1875.  
  1876.        Performance and File Size
  1877.        Performance and File Size
  1878.  
  1879.        I received  a letter  from someone which included a graph showing
  1880.        QSORT's performance  in sorting  time vs.  file size.  He said he
  1881.        had expected  an exponential,  or at  least a  logarithmic curve.
  1882.        Instead time increased linearly with file size.  I admit, it puz-
  1883.        zled me  at the time, but Codeview, Microsoft's debugger, made it
  1884.        ease for  me to  measure the  performance of the various parts of
  1885.        the QSORT  program.  It turns out that actual sorting of data ac-
  1886.        counts for  a very  small percentage of QSORT's running time.  It
  1887.        spends most  of its  time doing  I/O.   For files  up to about 50
  1888.        kilobytes, it  will read and write each record once.  From 50K to
  1889.        about 750K  there will  be one merge pass and each record will be
  1890.        read and  written twice.   Since the amount of I/O increases lin-
  1891.        early over this range of file sizes, so will sorting time.
  1892.  
  1893.        Above about  750K a second merge pass will be needed, but in this
  1894.        size range,  only seven  to ten  percent of the data will be pro-
  1895.        cessed in  the first  merge pass,  so the sort time vs size curve
  1896.        will steepen  slightly, but  will not experience a large step (as
  1897.        it did  in versions  1 and  2).   Doubling the  file size  to 1.5
  1898.        megabytes should increase the sort time about three times.
  1899.  
  1900.        Sorting time  will be  approximately proportional  to  file  size
  1901.        times the  "average passes  over data" number from the statistics
  1902.        report.   Since this  number remains a constant "2.0" over a wide
  1903.        range of  file sizes,  sorting time  will be a linear function of
  1904.        file size in that range.
  1905.  
  1906.        
  1907.  
  1908.        I hope  you find  this program useful.  Your comments and sugges-
  1909.        tions are welcome.
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.